#!/usr/bin/env python3
# by klaatu
# gpl 3 appears here

import sys
import os
import site

# Get launch script dir
launch_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
#print("Launch script dir: ", launch_dir)

# index 0 is usr local blah
# index 1 is usr lib(64) blah
PYTHONDIR = site.getsitepackages()[2]
print(PYTHONDIR) #DEBUG

# Update sys.path to include modules
d = 'planter'
if launch_dir == "/usr/bin":
    print("Running from installation...")
    modules_path = os.path.join(PYTHONDIR,d)
    print(modules_path) #DEBUG
else:
    print("Running from filesystem...")
    modules_path = os.path.join(launch_dir,"usr","lib","python3","site-packages",d)

# Get app.py module
sys.path.insert(0, modules_path)

#try:
import app
#except Exception:
#    print("Failed to import module app.py to launch Planter")
#    print("Installation was assumed to be at:", modules_path)
#    sys.exit(1)

# Launch application
app.getOptions()
